package com.xrtn.controller;

import com.xrtn.bean.SysAccountCardInfo;
import com.xrtn.bean.SysDiscountCardInfo;
import com.xrtn.bean.TCouponUsrRel;
import com.xrtn.service.ICommonService;
import com.xrtn.utils.CodeEnum;
import com.xrtn.utils.HttpUtils;
import com.xrtn.utils.ObjUtils;
import com.xrtn.utils.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by tu_pei on 2018/3/5.
 */
@Api("用户卡劵相关接口")
@Controller
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/card")
public class CardController {

    @Autowired
    private ICommonService commonService;


    /**
     * 进入卡券管理页面
     * @return
     */
    @RequestMapping(value = "/gotoCardManagement",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gotoCardManagement(ModelAndView modelAndView){
        modelAndView.setViewName("cardManagement/homePage");
        return modelAndView;
    }
    /**
     * 进入卡券管理页面
     * @return
     */
    @RequestMapping(value = "/gotoCouponManagement",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gotoCouponManagement(ModelAndView modelAndView){
        modelAndView.setViewName("cardManagement/couponPage");
        return modelAndView;
    }
    /**
     * 进入快速开卡页面管理页面
     * @return
     */
    @RequestMapping(value = "/gotoHomefastStorage",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gotoHomefastStorage(ModelAndView modelAndView){
        modelAndView.setViewName("home/homefastStorage");
        return modelAndView;
    }

    /**
     * 优惠券C端分享页面
     * @return
     */
    @RequestMapping(value = "/couponShare",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView couponShare(ModelAndView modelAndView){
        modelAndView.setViewName("couponShare");
        return modelAndView;
    }

    /**
     * 进入添加卡券管理页面
     * @return
     */
    @RequestMapping(value = "/gotoAddCard",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gotoAddCard(ModelAndView modelAndView){
        modelAndView.setViewName("cardManagement/addCard");
        return modelAndView;
    }
    /**
     * 进入添加优惠券管理页面
     * @return
     */
    @RequestMapping(value = "/couponContent",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView couponContent(ModelAndView modelAndView){
        modelAndView.setViewName("cardManagement/couponContent");
        return modelAndView;
    }
    /**
     * 进入添加卡项管理页面
     * @return
     */
    @RequestMapping(value = "/gotoAddCardInfo",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gotoAddCardInfo(ModelAndView modelAndView){
        modelAndView.setViewName("cardManagement/couponContent");
        return modelAndView;
    }

    /**
     * 进入快速储值
     * @return
     */
    @RequestMapping(value = "/gotoFastStorage",method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView gotoFastStorage(ModelAndView modelAndView){
        modelAndView.setViewName("home/homefastStorage");
        return modelAndView;
    }

    /**
     * @Title: selectSysAccountCardList
     * @Description: 查询储值卡列表
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询储值卡列表",notes="查询储值卡列表")
    @RequestMapping(value = "/selectSysAccountCardList",method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="cardName",dataType="string",required=false,value="名称",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardState",dataType="string",required=false,value="卡状态",defaultValue = "1"),
    })
    @ResponseBody
    public ResponseData selectSysAccountCardList(String cardName, String cardState){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        Map<String,Object> params = new HashMap<>();
        params.put("cardName", cardName);
        params.put("cardState", cardState);
        params.put("isDelete", 0);
        data.setResults(commonService.selectSysCardList(params));
        // 返回数据
        return data;
    }

    /**
     * @Title: selectSysAccountCardInfo
     * @Description: 查询储值卡详情
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询储值卡详情",notes="查询储值卡详情")
    @RequestMapping(value = "/selectSysAccountCardInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData selectSysAccountCardInfo(Integer cardId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        data.setResults(commonService.selectSysCardInfo(cardId));
        // 返回数据
        return data;
    }

    /**
     * @Title: selectSysCardList
     * @Description: 查询优惠券列表
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询优惠券列表",notes="查询优惠券列表")
    @RequestMapping(value = "/selectSysDiscountList",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData selectSysCardList(String cardName,Integer cardState){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        Map<String,Object> params = new HashMap<>();
        params.put("cardName", cardName);
        params.put("cardState", cardState);
        data.setResults(commonService.selectSysDiscountCardList(params));
        // 返回数据
        return data;
    }
    /**
     * @Title: selectSysDiscountInfo
     * @Description: 查询优惠券详情
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询优惠券详情",notes="查询优惠券详情")
    @RequestMapping(value = "/selectSysDiscountInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData selectSysDiscountInfo(Integer cardId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        data.setResults(commonService.selectSysDiscountCardInfo(cardId));
        // 返回数据
        return data;
    }
    /**
     * @Title: saveAccountCardInfo
     * @Description: 新增充值卡 || 计次卡
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "新增充值卡 || 计次卡",notes="新增充值卡 || 计次卡")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="cardName",dataType="string",required=false,value="名称",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardImg",dataType="string",required=false,value="图片",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardType",dataType="int",required=false,value="类型：1满减，2体验券，3优惠，4充值，5记次卡",defaultValue = "4"),
            @ApiImplicitParam(paramType="query",name="cardValue",dataType="double",required=false,value="原价",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="accountDiscount",dataType="double",required=false,value="售价",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="validTime",dataType="string",required=false,value="有效期",defaultValue = "2018-12-12"),
            @ApiImplicitParam(paramType="query",name="cardState",dataType="int",required=false,value="0:下架；1上架",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="serviceId",dataType="int",required=false,value="服务id",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardCount",dataType="int",required=false,value="次卡的次数",defaultValue = "1"),
    })
    @RequestMapping(value = "/saveSysAccountCardInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData saveSysAccountCardInfo(SysAccountCardInfo accountCardInfo){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
//        accountCardInfo.setCardValue(accountCardInfo.getAccountDiscount().intValue());
        data.setResults(commonService.saveSysAccountCardInfo(accountCardInfo));
        // 返回数据
        return data;
    }
    /**
     * @Title: updateSysAccountCardInfo
     * @Description: 修改充值卡 || 计次卡
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "修改充值卡 || 计次卡",notes="修改充值卡 || 计次卡")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="cardId",dataType="int",required=false,value="id",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardName",dataType="string",required=false,value="名称",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardImg",dataType="string",required=false,value="图片",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardType",dataType="int",required=false,value="类型：1满减，2体验券，3优惠，4充值，5记次卡",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardValue",dataType="double",required=false,value="实际金额",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="accountDiscount",dataType="double",required=false,value="优惠金额",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="validTime",dataType="string",required=false,value="有效期",defaultValue = "2018-12-12"),
            @ApiImplicitParam(paramType="query",name="cardState",dataType="int",required=false,value="0:下架；1上架",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="serviceId",dataType="int",required=false,value="服务id",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardCount",dataType="int",required=false,value="次卡的次数",defaultValue = "1"),
    })
    @RequestMapping(value = "/updateSysAccountCardInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData updateSysAccountCardInfo(SysAccountCardInfo accountCardInfo){
        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        data.setResults(commonService.updateSysAccountCardInfo(accountCardInfo));
        // 返回数据
        return data;
    }

    /**
     * @Title: saveServiceInfo
     * @Description: 新增优惠券信息
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "新增优惠券信息",notes="新增优惠券信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="cardId",dataType="int",required=false,value="id",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardName",dataType="string",required=false,value="名称",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardImg",dataType="string",required=false,value="图片",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardType",dataType="int",required=false,value="类型：1满减，2体验券，3优惠，4充值，5记次卡",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardCost",dataType="double",required=false,value="原价",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardCount",dataType="int",required=false,value="优惠券张数",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="discountCost",dataType="double",required=false,value="售价",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="targetCost",dataType="double",required=false,value="目标金额",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="discountCosts",dataType="double",required=false,value="优惠金额",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="validDay",dataType="string",required=false,value="有效期",defaultValue = "2018-12-12"),
            @ApiImplicitParam(paramType="query",name="cardState",dataType="int",required=false,value="0:下架；1上架",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="serviceId",dataType="int",required=false,value="服务id",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="discountDesc",dataType="String",required=false,value="使用说明",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="subclinicIds",dataType="int",required=false,value="门店范围",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardTotalTime",dataType="int",required=false,value="次数",defaultValue = "1"),
    })
    @RequestMapping(value = "/saveSysDiscountCardInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData saveSysDiscountCardInfo(SysDiscountCardInfo discountCardInfo, HttpServletRequest request){
        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        Map<String,Object> params = new HashMap<>();
        data.setResults(commonService.saveSysDiscountCardInfo(discountCardInfo, request));
        // 返回数据
        return data;
    }
    /**
     * @Title: updateSysDiscountCardInfo
     * @Description: 修改优惠券信息
     * @param @param userId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "修改优惠券信息",notes="修改优惠券信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="cardId",dataType="int",required=false,value="id",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardName",dataType="string",required=false,value="名称",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="cardImg",dataType="string",required=false,value="图片",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardType",dataType="int",required=false,value="类型：1满减，2体验券，3优惠，4充值，5记次卡",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardCost",dataType="double",required=false,value="原价",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="discountCost",dataType="double",required=false,value="售价",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="targetCost",dataType="double",required=false,value="目标金额",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="discountCosts",dataType="double",required=false,value="优惠金额",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="validDay",dataType="string",required=false,value="有效期",defaultValue = "2018-12-12"),
            @ApiImplicitParam(paramType="query",name="cardState",dataType="int",required=false,value="0:下架；1上架",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="serviceId",dataType="int",required=false,value="服务id",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="discountDesc",dataType="String",required=false,value="使用说明",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="subclinicIds",dataType="int",required=false,value="门店范围",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardTotalTime",dataType="int",required=false,value="次数",defaultValue = "1"),
    })
    @RequestMapping(value = "/updateSysDiscountCardInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData updateSysDiscountCardInfo(SysDiscountCardInfo discountCardInfo){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

//        if(discountCardInfo.getCardState() ==1){
//            discountCardInfo.setCardState(0);
//        }else{
//            discountCardInfo.setCardState(1);
//        }

        data.setResults(commonService.updateSysDiscountCardInfo(discountCardInfo));
        // 返回数据
        return data;
    }

    /**
     * @Title: deleteSysDiscountCardInfo
     * @Description: 删除卡券信息
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "删除卡券信息",notes="删除卡券信息")
    @RequestMapping(value = "/deleteSysDiscountCardInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData deleteSysDiscountCardInfo(Integer cardId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        if(commonService.deleteSysDiscountCardInfo(cardId) < 0){
            data.setCodeEnum(CodeEnum.CODE_6);
            return data;
        }
        // 返回数据
        return data;
    }
    /**
     * @Title: deleteSysDiscountCardInfo
     * @Description: 删除卡券信息
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "删除卡信息",notes="删除卡券信息")
    @RequestMapping(value = "/deleteSysAccountCardInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData deleteSysAccountCardInfo(Integer cardId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        if(commonService.deleteSysAccountCardInfo(cardId) < 0){
            data.setCodeEnum(CodeEnum.CODE_6);
            return data;
        }
        // 返回数据
        return data;
    }

    /**
     * @Title: deleteUserCardInfo
     * @Description: 删除用户计次卡
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "删除卡信息",notes="删除卡券信息")
    @RequestMapping(value = "/deleteUserCardInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData deleteUserCardInfo(Integer relId){

        // 创建响应Model
        ResponseData data = new ResponseData();

        Integer result = commonService.deleteUserCardInfo(relId);

        if(result == 1){
            data.setCodeEnum(CodeEnum.CODE_60026);
            return data;
        }
        data.setResults(result);
        return data;
    }

    /**
     * @Title: selectAccountList
     * @Description: 查询卡项列表
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询卡项列表",notes="查询卡项列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="userPhone",dataType="string",required=false,value="手机号",defaultValue = "123"),
            @ApiImplicitParam(paramType="query",name="startDate",dataType="string",required=false,value="开始时间",defaultValue = "2018-03-06 12:00"),
            @ApiImplicitParam(paramType="query",name="endDate",dataType="string",required=false,value="结束时间",defaultValue = "2018-03-06 12:00"),
            @ApiImplicitParam(paramType="query",name="dayType",dataType="int",required=false,value="时间类型：0全部 1:今天，2：3天内，3：七天",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="payWay",dataType="int",required=false,value="支付方式:0:余额;1:支付宝二维码;2:微信二维码;3:现金;4:信用卡;5:次卡",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="cardType",dataType="int",required=false,value="全部：空，储值：1，次卡：2",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="subclinicId",dataType="int",required=false,value="分店id",defaultValue = "1"),
    })
    @RequestMapping(value = "/selectAccountList",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData selectAccountList(String userPhone,String startDate,String endDate,
                                          Integer dayType,Integer payWay,Integer subclinicId,Integer cardType){

        // 创建响应Model
        ResponseData data = new ResponseData();

        Map<String,Object> retMap = new HashMap<>();
        retMap.put("userPhone",userPhone);
        retMap.put("startDate",startDate);
        retMap.put("endDate",endDate);
        //今天 3tian ,7tian
        retMap.put("dayType",dayType);
        // 0 全部 ： 1 储值卡 2 计次卡
        retMap.put("cardType",cardType);
        //支付方式:0:余额;1:支付宝二维码;2:微信二维码;3:现金;4:信用卡;5:次卡
        retMap.put("payWay",payWay);
        retMap.put("subclinicId",subclinicId);

        // 调用Service
        data.setResults(commonService.selectAccountList(retMap));
        // 返回数据
        return data;
    }

    /**
     * @Title: saveUserCard
     * @Description: 用户开卡
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "用户开卡",notes="用户开卡")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="cardId",dataType="int",required=false,value="卡id",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="userId",dataType="int",required=false,value="用户id",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardType",dataType="int",required=false,value="卡类型：1满减，2体验券，3通用，4充值，5记次卡",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="doctorId",dataType="int",required=false,value="大夫id",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="subclinicId",dataType="int",required=false,value="分店id",defaultValue = "0"),
            @ApiImplicitParam(paramType="query",name="cardDesc",dataType="string",required=false,value="卡项订单备注",defaultValue = "0"),
    })
    @RequestMapping(value = "/saveUserCard",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData saveUserCard(Integer cardId, Integer userId,Integer payWay,Integer cardType,Integer doctorId,Integer subclinicId, String cardDesc){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        if(commonService.saveUserCard(cardId, userId, cardType, doctorId, subclinicId, payWay, cardDesc) == 0){
            data.setCodeEnum(CodeEnum.CODE_6);
            return data;
        }
        // 返回数据
        return data;
    }
    /**
     * @Title: saveUserCoupon
     * @Description: 发放优惠券
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "发放优惠券",notes="发放优惠券")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="cardId",dataType="int",required=false,value="卡id",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="userId",dataType="int",required=false,value="用户id",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="cardType",dataType="int",required=false,value="卡类型：1满减，2体验券，3通用，4充值，5记次卡",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="validDay",dataType="int",required=false,value="有效期天数",defaultValue = "20"),
            @ApiImplicitParam(paramType="query",name="userCouponArray",dataType="string",required=false,value="有效期天数",defaultValue = "[{" + "\"cardId\": 1," + "\"userId\": 56," + "\"couponId\": 3," + "\"cardType\": 1," + "\"validDay\": 12" + "}, {" + "\"cardId\": 1," + "\"couponId\": 3,"+"\"userId\": 57," + "\"cardType\": 1," + "\"validDay\": 12" + "}]"),
    })
    @RequestMapping(value = "/saveUserCoupon",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData saveUserCoupon(String userCouponArray){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        Integer count = commonService.saveUserCoupon(userCouponArray);
        if(count <= 0){
            data.setCodeEnum(CodeEnum.CODE_60009);
            return data;
        }
        // 返回数据
        return data;
    }

    /**
     * @Title: saveUserCoupon
     * @Description: 发放优惠券
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "微信端-领取优惠券",notes="微信端-领取优惠券")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="couponId",dataType="int",required=false,value="券id",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="userPhone",dataType="int",required=false,value="手机号",defaultValue = "1"),
    })
    @RequestMapping(value = "/useCoupon",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData useCoupon(Integer couponId,String userPhone){

        // 创建响应Model
        ResponseData data = new ResponseData();

        if(ObjUtils.isEmpty(couponId)){
            data.setCodeEnum(CodeEnum.CODE_60015);
            return data;
        }
        if(ObjUtils.isEmpty(userPhone)){
            data.setCodeEnum(CodeEnum.CODE_60010);
            return data;
        }

        // 调用Service
        return commonService.saveUseCoupon(couponId, userPhone, data);
    }
    /**
     * @Title: selectUnUseCouponList
     * @Description: 用户开卡
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询未领券的用户列表",notes="根据门店|姓名|手机号")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="couponId",dataType="int",required=false,value="卡id",defaultValue = "2"),
            @ApiImplicitParam(paramType="query",name="subclinicId",dataType="int",required=false,value="分店id",defaultValue = "1"),
            @ApiImplicitParam(paramType="query",name="userPhone",dataType="string",required=false,value="昵称或者手机号模糊匹配",defaultValue = "2"),
    })
    @RequestMapping(value = "/selectUnUseCouponList",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData selectUnUseCouponList(HttpServletRequest request){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service
        Map<String,Object> params = HttpUtils.getAllReqParams(request);

        data.setResults(commonService.selectUnUseCouponList(params));
        // 返回数据
        return data;
    }
}
